﻿CREATE PROCEDURE [dbo].[LastEntries]

AS
SELECT MAX(el.EntryDate) AS LastEntry, u.FullName, ut.TypeName
FROM  EntryLog el INNER JOIN
               Users u ON el.UserID = u.UserID INNER JOIN
               UserType ut ON u.UserTypeID = ut.UserTypeID
GROUP BY u.FullName, u.UserID, u.UserTypeID, ut.TypeName
ORDER BY u.UserTypeID DESC, LastEntry DESC

